
export default function Scrollto(vm) {
	if(vm.msglist.length===0){
		return
	}

  const viewId = `#msgall-${vm.msglist[vm.msglist.length-1].timestamp}`;
  
  // 使用 $nextTick 确保 DOM 已更新
  vm.$nextTick(() => {
    const query = uni.createSelectorQuery().in(vm);
    
    query
      .select(viewId)
      .boundingClientRect()
      .selectViewport()
      .scrollOffset()
      .exec(([elementRect, scrollInfo]) => {
        if (!elementRect) {
          console.error('未找到目标元素：', viewId);
          return;
        }
        
        const targetScrollTop = scrollInfo.scrollTop + elementRect.top;
		
	    vm.scrollTop=targetScrollTop+300
				console.log(vm.scrollTop)
        // uni.pageScrollTo({
        //   scrollTop: targetScrollTop,
        //   duration: 100
        // });
      });
  });
}